include $(TOPDIR)/rules.mk

PKG_NAME:=mox
PKG_RELEASE:=1

PKG_SOURCE_PROTO:=git
PKG_SOURCE_URL:=https://github.com/mjl-/mox.git
#PKG_SOURCE_DATE:=2025-02-20
PKG_SOURCE_VERSION=a4589207215156d71a14cd30bb367876b175f124
PKG_MIRROR_HASH:=skip

PKG_LICENSE:=MIT
PKG_MAINTAINER:=JoyNine<joyplayer@126.com>

PKG_BUILD_DEPENDS:=golang/host node/host node-yarn/host
PKG_BUILD_PARALLEL:=1
PKG_BUILD_FLAGS:=no-mips16

GO_PKG:=github.com/mjl-/mox
GO_PKG_BUILD_PKG:=github.com/mjl-/mox

include $(INCLUDE_DIR)/package.mk
include $(TOPDIR)/feeds/packages/lang/golang/golang-package.mk

define Package/mox
  SECTION:=mail
  CATEGORY:=Mail
  TITLE:=A mail server in Go.
  URL:=https://wiki.metacubex.one
  DEPENDS:=$(GO_ARCH_DEPENDS) +ca-bundle
  USERID:=mox=891:mox=891
endef

define Package/mox/description
  Mox is a modern full-featured open source secure mail server for low-maintenance self-hosted email.
endef

define Package/mox/conffiles
/etc/config/mox
/etc/mox/mox.conf
/etc/mox/domains.conf
endef

define Package/mox/install
	$(call GoPackage/Package/Install/Bin,$(1))

	$(INSTALL_DIR) $(1)/etc/config
	$(INSTALL_CONF) $(CURDIR)/files/mox.config $(1)/etc/config/mox
	
	$(INSTALL_DIR) $(1)/etc/init.d
	$(INSTALL_BIN) $(CURDIR)/files/mox.init $(1)/etc/init.d/mox
endef

$(eval $(call GoBinPackage,mox))
$(eval $(call BuildPackage,mox))
